/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package astroLib;

/**
 *
 * @author mgeden
 */
public class Equatorial {
      double RA; //right ascension (α) -also RA-, or hour angle (H) -also HA- 
      double Dec; //declination (δ) 

        Equatorial() {}
        Equatorial(double X, double Y) {
            this.RA=X;this.Dec=Y;
        }
        
       Horizontal Equ2Hor ( double lat, double longitude, double mjd)
          {
          //
          // Variables
          //
         
            double lambda=longitude;
            double tau = APC_Time.GMST(mjd) + lambda - RA;//mRightAscension=619295031762998857e-17
            APC_Vect3D.Vec3D e_equ;
            APC_Vect3D.Polar  e_hor;
            Horizontal result;
            APC_Vect3D.Polar polar=new APC_Vect3D.Polar(tau,Dec);//mDeclination=-3904872466421424175e-20

            e_equ = new APC_Vect3D.Vec3D(polar);          // unit vector in horizontal system
             // e_equ = {m_Vec = {0.58881464761003832, -0.38575765187682981, 0.71027342958774764}, m_phi = -0.57998202437182178, m_theta = 0.78988656845716043, m_r = 1, m_bPolarValid = true}
             // R_y(pi/2.0-lat)={m_Mat = {{0.74431154623115414, 0, -0.66783255547104659}, {0, 1, 0}, {0.66783255547104659, 0, 0.74431154623115414}}}      
            e_hor=APC_Vect3D.calcPolarAngles (APC_Vect3D.AbProduct(APC_Vect3D.R_y(Math.PI/2.0-lat), e_equ)); // unit vector in equatorial system
              //  e_hor = {m_Vec = {-0.036082178758590183, -0.38575765187682981, 0.92189430543555695}, m_phi = 0, m_theta = 0, m_r = 0, m_bPolarValid = false}
          
            result= new Horizontal ();

     /*       result.Az =e_hor.phi;                     // polar angles4.6191244648066796
            result.h  =e_hor.theta;                   //1.1729416588203474*/
            result.Az=Math.toDegrees((e_hor.phi>Math.PI) ? e_hor.phi-Math.PI :e_hor.phi+Math.PI);
            //result.Az=Math.toDegrees(e_hor.phi);
            result.h  =Math.toDegrees(e_hor.theta);    

          return result;

        }

 
    }